import 'iview/dist/styles/iview.css'
import 'babel-polyfill'

import Vue from 'vue'
import Store from './store'
import Router from './router'
import {sync} from 'vuex-router-sync'
import iview from 'iview'

import VueSocketio from 'vue-socket.io';
// Vue.use(VueSocketio, `http://10.1.40.152:9092`);

import conf from './../conf'

import ui from './ui'

// const i18n = new VueI18n({
//     locale: Vue.config.lang,
//     fallbackLocale: 'en',
//     messages
// })

Vue.use(ui)
Vue.use(iview)

class Chat {

  constructor(config = {}) {
    this._conf = conf
    this._store = new Store()
    const routes = {
      routes: [
        {
          path: '/',
          component: () => import ('@biz/chat.index/views/index')
        }, {
          path: '/Test',
          component: () => import ('@biz/chat.index/views/index')
        }
      ]
    }
    this._router = new Router(routes)
    this._app = new Vue({store: this.store, router: this.router});
    // sync(this.store, this.router)

    this._ready = new Promise((resolve, reject) => {
      this._readyResolve = resolve
    })

    // this._router.addRoutes(routes)

    // console.log(this.router.options.routes)
  }

  get conf() {
    return this._conf
  }

  get store() {
    return this._store
  }

  get router() {
    return this._router
  }

  get app() {
    return this._app
  }

  ready() {
    return this._ready
  }

  readyResolve() {
    return this._readyResolve()
  }

}

export default Chat
